package com.me.mygdxgame;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;


public class MyGdxGame implements ApplicationListener {
	private long lastRender;

	

	/**
	 * Holder of the texture for the various non-map sprites the game will have.
	 */
	
	/**
	 * This is the main box2d "container" object. All bodies will be loaded in
	 * this object and will be simulated through calls to this object.
	 */
	private World world;
	GameWorld game;


	public static final float PIXELS_PER_METER = 60f;

	
	@Override
	public void create() {	
		
		
			

		Assents.load();

		/**
		 * You can set the world's gravity in its constructor. Here, the gravity
		 * is negative in the y direction (as in, pulling things down).
		 */
		world = new World(new Vector2(0.0f, -15.0f), true);
		game= new GameWorld(world);
		

		


		lastRender = System.nanoTime();
		
	}

	@Override
	public void dispose() {
	}

	@Override
	public void render() {		
		long now = System.nanoTime();

		game.Update(Gdx.app.getGraphics().getDeltaTime());
		game.Render();
		
	
		now = System.nanoTime();
		if (now - lastRender < 30000000) { // 30 ms, ~33FPS
			try {
				Thread.sleep(6);
			} catch (InterruptedException e) {
			}
		}

		lastRender = now;
		
	}

	@Override
	public void resize(int width, int height) {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}
}
